//
//  SAReturnGoodsCell.m
//  saasRetail
//
//  Created by 黄志刚 on 2021/7/20.
//

#import "SAReturnGoodsCell.h"

@interface SAReturnGoodsCell ()

@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *colourSizeLab;
@property (nonatomic, strong) UILabel *numLab;
@property (nonatomic, strong) UIImageView *iconImageV;
@property (nonatomic, strong) UILabel *priceLab;

@end

@implementation SAReturnGoodsCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

-(void)setModel:(SASaleSkuListModel *)model {
    _model = model;
    [self.iconImageV sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"sale_bule_defaul"]];
    self.titleLab.text = model.productName;
    self.colourSizeLab.text = [NSString stringWithFormat:@"%@,%@",model.colourName,model.sizeName];
    self.numLab.text = model.stock;
    self.priceLab.text = [NSString stringWithFormat:@"%0.2lf",[model.skuActualPrice doubleValue]/100.f];
}

#pragma mark - initUI
-(void)initUI {
    UIView *line = [[UIView alloc] initWithFrame:SARectMake(0, 0, kBaseScreenWidth, 1)];
    line.backgroundColor = kLineColor;
    [self.contentView addSubview:line];
    
    UIImageView *iconImageV = [[UIImageView alloc] initWithFrame:SARectMake(20, 10, 30, 35)];
    iconImageV.image = [UIImage imageNamed:@"sale_bule_defaul"];
    [self.contentView addSubview:iconImageV];
    iconImageV.contentMode = UIViewContentModeScaleAspectFit;
    self.iconImageV = iconImageV;
    
    [self.contentView addSubview:self.titleLab];
    [self.contentView addSubview:self.colourSizeLab];
    [self.contentView addSubview:self.numLab];
    [self.contentView addSubview:self.priceLab];
}

-(UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] initWithFrame:SARectMake(60, 11, 130, 15)];
        _titleLab.textColor = kBlackColor;
        _titleLab.font = kFont(13);
    }
    return _titleLab;
}

-(UILabel *)colourSizeLab {
    if (!_colourSizeLab) {
        _colourSizeLab = [[UILabel alloc] initWithFrame:SARectMake(60, 29, 130, 15)];
        _colourSizeLab.textColor = kLightgGrayColor;
        _colourSizeLab.font = kFont(13);
    }
    return _colourSizeLab;
}

-(UILabel *)numLab {
    if (!_numLab) {
        _numLab = [[UILabel alloc] initWithFrame:SARectMake(195, 0, 40, 55)];
        _numLab.textColor = kBlackColor;
        _numLab.font = kFont(13);
        _numLab.textAlignment = NSTextAlignmentLeft;
    }
    return _numLab;
}

-(UILabel *)priceLab {
    if (!_priceLab) {
        _priceLab = [[UILabel alloc] initWithFrame:SARectMake(235, 0, 120, 55)];
        _priceLab.textColor = kBlackColor;
        _priceLab.font = kFont(13);
        _priceLab.textAlignment = NSTextAlignmentRight;
    }
    return _priceLab;
}

@end
